package flowWIndow.f1;

public class test643 {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {1, 12, -5, -6, 50, 3};
        int k = 4;
        double max = solution.findMaxAverage(nums, k);
        System.out.println(max);
    }
}

class Solution {
    public double findMaxAverage(int[] nums, int k) {
        int n = nums.length;
        int value = 0;
        for (int i = 0; i < k; i++) {
            value += nums[i];
        }
        int max = value;
        for (int i = k; i < n; i++) {
            value = value - nums[i - k] + nums[i];
            if (value > max) {
                max = value;
            }
        }
        return (double) max / k;
    }
}